package com.gettong.test.SpringCloudFeignConsumer.controller;

import com.gettong.test.SpringCloudCommon.entity.User;
import com.gettong.test.SpringCloudCommon.feign.UserFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by gettong on 2019/11/30.
 */
@RestController
@RequestMapping("/user-feign")
public class UserFeignController {

    @Autowired
    private UserFeign userFeign;

    @GetMapping("/list")
    public void list() {
        List<User> userList = userFeign.list();
        System.out.println(userList);
    }

    @GetMapping("/get")
    public void get() {
        User user = userFeign.get(3L);
        System.out.println(user);
    }

    @GetMapping("/save")
    public void save() {
        User user = new User(3L, "gettong3", 38);
        userFeign.save(user);
    }

    @GetMapping("/delete")
    public void delete() {
        userFeign.delete(3L);
    }

}
